package com.bskj.bms.bean.vo;

import com.bskj.common.bean.model.BmsRole;
import com.bskj.common.bean.model.BmsUser;
import com.bskj.common.bean.model.ParkingLotCustomer;
import com.bskj.common.bean.model.ParkingShop;
import com.bskj.common.enums.BmsUserTypeEnum;
import com.bskj.common.utils.DateTimeUtil;

/**
 * 全部用户信息
 * 
 * @author lishi
 * @date 2018年5月8日 上午10:28:06
 */
public class AllInfoUserVo extends BmsUser {
	private ParkingLotCustomer parkingLotCustomer;
	private ParkingShop parkShop;
	private BmsRole bmsRole;

	public ParkingLotCustomer getParkingLotCustomer() {
		return parkingLotCustomer;
	}

	public void setParkingLotCustomer(ParkingLotCustomer parkingLotCustomer) {
		this.parkingLotCustomer = parkingLotCustomer;
	}

	public ParkingShop getParkShop() {
		return parkShop;
	}

	public void setParkShop(ParkingShop parkShop) {
		this.parkShop = parkShop;
	}

	public BmsRole getBmsRole() {
		return bmsRole;
	}

	public void setBmsRole(BmsRole bmsRole) {
		this.bmsRole = bmsRole;
	}
	
	public String getRoleName() {
		if(bmsRole != null) {
			return bmsRole.getName();
		}
		return "";
	}
	
	public String getCreateTimeStr() throws Exception {
		if(getCreateTime() != null) {
			return DateTimeUtil.date2String(getCreateTime());
		}
		return "";
	}
	
	public String getOwnName() {
		if(getType() == BmsUserTypeEnum.sys_user.getKey()) {
			return "泊数科技有限公司";
		}
		if(getType() == BmsUserTypeEnum.parking_lot_user.getKey()) {
			if(parkingLotCustomer != null) {
				return parkingLotCustomer.getName();
			}
			return "未知的车场！";
		}
		if(getType() == BmsUserTypeEnum.parking_shop_user.getKey()) {
			String str = "";
			if(parkingLotCustomer != null) {
				str += parkingLotCustomer.getName();
			} else {
				str +=  "未知的车场！";
			}
			
			if(parkShop != null) {
				str += "-" + parkShop.getName();
			} else {
				str += "-未知的商场！" + parkShop.getName();
			}
			return str;
		}
		return "";
	}
}